lerp by timer unity

52

lerp by timer unity -

float lerpDuration = 3; 
float startValue = 0; 
float endValue = 10; 
float valueToLerp;
void Start()
    {
        StartCoroutine(Lerp());
    }
IEnumerator Lerp()
    {
        float timeElapsed = 0;
        while (timeElapsed < lerpDuration)
        {
            valueToLerp = Mathf.Lerp(startValue, endValue, timeElapsed / lerpDuration);
            timeElapsed += Time.deltaTime;
            yield return null;
        }
        valueToLerp = endValue;
    }

Comments

Submit
0 Comments